from flask import Blueprint, request
from ..controllers.contact import (
    create_contact,
    get_contacts,
    get_contact,
    update_contact,
    delete_contact
)

# 创建联系人蓝图
contact_bp = Blueprint('contact', __name__)

# 路由定义 - 使用POST方法
@contact_bp.route('/contacts/add', methods=['POST'])
def route_create_contact():
    return create_contact()

@contact_bp.route('/contacts/list', methods=['GET'])
def route_get_contacts():
    data = request.args.to_dict() or {}
    return get_contacts(data)

@contact_bp.route('/contacts/contact', methods=['GET'])
def route_get_contact():
    data = request.args.to_dict() or {}
    return get_contact(data)

@contact_bp.route('/contacts/edit', methods=['POST'])
def route_update_contact():
    return update_contact()

@contact_bp.route('/contacts/delete', methods=['POST'])
def route_delete_contact():
    return delete_contact()